package com.aliyun.dao;


import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component("nikeDao")
@Transactional
public class NikeDao extends CommonDao{
	
	public int insertNikeOrder(Map<String, String> map)throws SQLException{
		return this.getSqlSession().insert("com.aliyun.dao.NikeMapper.insertNikeOrder",map);
	}
	public int insertNikeOrderDetail(Map<String, String> map)throws SQLException{
		//查询数据库,有的话就 修改，没有就插入
		Map<String, Object> orderMap = this.getSqlSession().selectOne("com.aliyun.dao.NikeMapper.getOneNikeOrderDetail",map);
		if(orderMap!=null && orderMap.size()>0){
			this.getSqlSession().update("com.aliyun.dao.NikeMapper.updateNikeOrderDetail",map);
		}else{
			this.getSqlSession().insert("com.aliyun.dao.NikeMapper.insertNikeOrderDetail",map);
		}
		return 1;
	}
	public Map<String, Object> getOneNikeOrder()throws SQLException{
		Map<String, Object> orderMap = this.getSqlSession().selectOne("com.aliyun.dao.NikeMapper.getOneNikeOrder");
		this.getSqlSession().update("com.aliyun.dao.NikeMapper.updateNikeOrder",orderMap);
		return orderMap;
    }
	public List<Map<String, Object>> getAllNikeOrder(Map<String,String> map)throws SQLException{
		List<Map<String, Object>> orderList = this.getSqlSession().selectList("com.aliyun.dao.NikeMapper.getAllNikeOrder",map);
		return orderList;
    }
	public List<Map<String, Object>> getAllNikeOrderDetail(Map<String,String> map)throws SQLException{
		List<Map<String, Object>> orderList = this.getSqlSession().selectList("com.aliyun.dao.NikeMapper.getAllNikeOrderDetail",map);
		return orderList;
    }
	public List<Map<String, Object>> getAllBaiLian()throws SQLException{
		List<Map<String, Object>> orderList = this.getSqlSession().selectList("com.aliyun.dao.NikeMapper.getAllBaiLian");
		return orderList;
    }
}
